﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using IterationLife.ContentResources.Enums;
using IterationLife.Extensions.Dtos;
using Util.Applications;

namespace IterationLife.PlatformBackEnd.AppServices.Dtos.ContentResources
{
    /// <summary>
    /// 内容资源数据传输对象
    /// </summary>
    [DataContract]
    public class ContentResourceDto : DtoBase
    {

        /// <summary>
        /// 初始化内容资源数据传输对象
        /// </summary>
        public ContentResourceDto()
        {
            PictureDtos = new List<ContentResourcePictureDto>();
            SingleBanner = new Resources();
            MultiBanners = new List<Resources> { new Resources(), new Resources(), new Resources() };
            SystemBanners = new List<Resources>();
            Video = new Resources();
            TagList = new List<string>();
        }

        /// <summary>
        /// 分类编号
        /// </summary>
        [Display(Name = "分类编号")]
        [DataMember]
        public Guid? CategoriyId { get; set; }

        /// <summary>
        /// 分类名称
        /// </summary>
        [Display(Name = "分类名称")]
        [DataMember]
        public string CategoriyName { get; set; }

        /// <summary>
        /// 类型
        /// </summary>
        [Required(ErrorMessage = "类型不能为空")]
        [Display(Name = "类型")]
        [DataMember]
        public ContentResourceType? Type { get; set; }

        /// <summary>
        /// 类型
        /// </summary>
        [Display(Name = "类型")]
        [DataMember]
        public string TypeDescription => Type.Description();

        /// <summary>
        /// 标题
        /// </summary>
        [Required(ErrorMessage = "标题不能为空")]
        [StringLength(100, ErrorMessage = "标题输入过长，不能超过100位")]
        [Display(Name = "标题")]
        [DataMember]
        public string Title { get; set; }

        /// <summary>
        /// 单封面图
        /// </summary>
        [Display(Name = "单封面图")]
        [DataMember]
        public Resources SingleBanner { get; set; }

        /// <summary>
        /// 多封面图
        /// </summary>
        [Display(Name = "多封面图")]
        [DataMember]
        public List<Resources> MultiBanners { get; set; }

        /// <summary>
        /// 系统封面集合
        /// </summary>
        [Display(Name = "系统封面集合")]
        [DataMember]
        public List<Resources> SystemBanners { get; set; }

        /// <summary>
        /// 封面类型
        /// </summary>
        [Required(ErrorMessage = "封面类型不能为空")]
        [Display(Name = "封面类型")]
        [DataMember]
        public ContentResourceBannerType? BannerType { get; set; }

        /// <summary>
        /// 富文本
        /// </summary>
        [Display(Name = "富文本")]
        [DataMember]
        public string RichText { get; set; }

        /// <summary>
        /// 视频
        /// </summary>
        [Display(Name = "视频")]
        [DataMember]
        public Resources Video { get; set; }

        /// <summary>
        /// 简介
        /// </summary>
        [StringLength(1000, ErrorMessage = "简介输入过长，不能超过1000位")]
        [Display(Name = "简介")]
        [DataMember]
        public string BriefIntroduction { get; set; }

        /// <summary>
        /// 标签
        /// </summary>
        [Display(Name = "标签")]
        [DataMember]
        public List<string> TagList { get; set; }

        /// <summary>
        /// 标签
        /// </summary>
        [StringLength(800, ErrorMessage = "标签输入过长，不能超过800位")]
        [Display(Name = "标签")]
        [DataMember]
        public string Tags { get; set; }

        /// <summary>
        /// 是否定时发表
        /// </summary>
        [Required(ErrorMessage = "是否定时发表不能为空")]
        [Display(Name = "是否定时发表")]
        [DataMember]
        public bool? IsRegularPublication { get; set; }

        /// <summary>
        /// 发表时间
        /// </summary>
        [Display(Name = "发表时间")]
        [DataMember]
        public DateTime? PublicationTime { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        [Required(ErrorMessage = "状态不能为空")]
        [Display(Name = "状态")]
        [DataMember]
        public ContentResourceState? State { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        [Display(Name = "状态")]
        [DataMember]
        public string StateDescription => State.Description();

        /// <summary>
        /// 创建时间
        /// </summary>
        [Display(Name = "创建时间")]
        [DataMember]
        public DateTime? CreationTime { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [Display(Name = "创建人")]
        [DataMember]
        public Guid? CreatorId { get; set; }

        /// <summary>
        /// 最后修改时间
        /// </summary>
        [Display(Name = "最后修改时间")]
        [DataMember]
        public DateTime? LastModificationTime { get; set; }

        /// <summary>
        /// 最后修改人
        /// </summary>
        [Display(Name = "最后修改人")]
        [DataMember]
        public Guid? LastModifierId { get; set; }

        /// <summary>
        /// 是否删除
        /// </summary>
        [Required(ErrorMessage = "是否删除不能为空")]
        [Display(Name = "是否删除")]
        [DataMember]
        public bool IsDeleted { get; set; }

        /// <summary>
        /// 版本号
        /// </summary>
        [Display(Name = "版本号")]
        [DataMember]
        public Byte[] Version { get; set; }

        /// <summary>
        /// 输出内容资源状态
        /// </summary>
        public override string ToString()
        {
            return this.ToEntity().ToString();
        }

        /// <summary>
        /// 内容资源图集数据传输对象集合
        /// </summary>
        [Display(Name = "内容资源图集数据传输对象集合")]
        [DataMember]
        public List<ContentResourcePictureDto> PictureDtos { get; set; }

    }
}
